<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    String ctx = request.getContextPath();
    request.setAttribute("ctx", ctx);
%>
<html>
<head>
    <title>Title</title>
    <script src="js/jquery-1.8.2.min.js"></script>
    <script src="js/fileupload.js"></script>
    <script src="My97DatePicker/WdatePicker.js"></script>
    <link rel="stylesheet" href="css/img.css">
    <link rel="stylesheet" href="bootstrap-3.3.7/dist/css/bootstrap.css">
    <script>
        function fenye(cpage) {
            $("[name='cpage']").val(cpage);
            $("form").submit();
        }
        function toadd() {
            location="toadd.do";
        }
        function del(sid) {
            $.ajax({
                       url:"del.do",
                       type:"post",
                       data:{"sid":sid},
                       dataType:"json",
                       success:function(obj) {
                            if (obj>0){
                                alert("删除成功");
                                location="list.do";
                            }
                       }
                  })
        }
    </script>
</head>
<body>
<form action="list.do" method="post">
    <input type="hidden" name="cpage">
</form>
<input type="button" value="添加" onclick="toadd()">
    <table>
        <tr>
            <td>编号</td>
            <td>商品名称</td>
            <td>商品品牌</td>
            <td>规格型号</td>
            <td>价格</td>
            <td>上架时间</td>
            <td>操作</td>
        </tr>
        <c:forEach items="${pageInfo.list}" var="g">
            <tr>
                <td>${g.sid}</td>
                <td>${g.sname}</td>
                <td>${g.style}</td>
                <td>${g.bname}</td>
                <td>${g.sprice}</td>
                <td>${g.stime}</td>
                <td>

                    <input type="button" value="删除" onclick="del(${g.sid})">
                </td>
            </tr>
        </c:forEach>
        <tr>
            <td colspan="11">
                <input type="button" value="首页" onclick="fenye(1)">
                <input type="button" value="上一页" onclick="fenye(${pageInfo.isFirstPage?1:pageInfo.prePage})">
                <input type="button" value="下一页" onclick="fenye(${pageInfo.isLastPage?pageInfo.pages:pageInfo.nextPage})">
                <input type="button" value="尾页" onclick="fenye(${pageInfo.pages})">
            </td>
        </tr>
    </table>
</body>
</html>
